package com.gitee.feizns.itrip.personal.biz.service;

import com.gitee.feizns.itrip.personal.beans.vo.Page;
import com.gitee.feizns.itrip.personal.biz.entity.ao.ForAcceptCommentAdd;
import com.gitee.feizns.itrip.personal.biz.entity.ao.ForAcceptGetCommentList;
import com.gitee.feizns.itrip.personal.biz.entity.vo.ForViewGetCommentList;
import com.gitee.feizns.itrip.personal.biz.entity.vo.ForViewGetCount;
import com.gitee.feizns.itrip.personal.biz.entity.vo.ForViewGetImg;
import com.gitee.feizns.itrip.personal.biz.entity.vo.ForViewHotelLable;
import com.gitee.feizns.itrip.personal.biz.entity.vo.ForViewHotelScore;
import com.gitee.feizns.itrip.personal.utils.Utils;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.List;

/**
 * @author feizns
 * @since 2019/1/9 0009
 */
public interface CommentService {

    /**
     * 评论图片路径前缀
     */
    String COMMENT_IMAGE_PREFIX = "http://47.110.229.79/comment/";

    /**
     * 图片随机数位数
     */
    int RANDOM_NUMBER_LENGTH = 7;

    /**
     * 图片生成分割符
     */
    String COMMENT_IMAGE_SEPARATOR = "-";

    /**
     * 评论编号
     * @param commentId
     * @return
     */
    List<ForViewGetImg> getImg(Integer commentId);

    /**
     * 获取指定的评论列表
     * @param condition
     * @return
     */
    Page<ForViewGetCommentList> getCommentList(ForAcceptGetCommentList condition);

    /**
     * 获取指定酒店评论信息
     * @param hotelId
     * @return
     */
    ForViewGetCount getCount(Integer hotelId);

    /**
     * 根据酒店编号获取酒店的评论分数信息
     * @param hotelId
     * @return
     */
    ForViewHotelScore getHotelScore(Integer hotelId);

    /**
     * 获取所有的出游类型
     * @return
     */
    List<ForViewHotelLable> getTravelType();

    /**
     * 新增评论
     * @param comment
     */
    void add(ForAcceptCommentAdd comment, Long curtUserId);

    /**
     * 上传文件到服务器
     * @param file
     * @param curtUserId
     * @param suffix
     * @return
     */
    String[] uploadImg(InputStream file, Long curtUserId, String suffix);

    /**
     * 图片url生成策略
     * @param curtUserId
     * @param suffix
     * @return
     */
    static String generateImageUrl(Long curtUserId, String suffix) {
        return new StringBuilder()
                .append(curtUserId)
                .append(COMMENT_IMAGE_SEPARATOR)
                .append(System.currentTimeMillis())
                .append(COMMENT_IMAGE_SEPARATOR)
                .append(Utils.getNumber(RANDOM_NUMBER_LENGTH))
                .append(suffix)
                .toString();
    }

}
